class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table "users", :force => true do |t|
      t.column :login,                     :string, :limit => 40
      t.column :name,                      :string, :limit => 100, :default => '', :null => true
      t.column :email,                     :string, :limit => 100
      t.column :crypted_password,          :string, :limit => 40
      t.column :salt,                      :string, :limit => 40
      t.column :created_at,                :datetime
      t.column :updated_at,                :datetime
      t.column :remember_token,            :string, :limit => 40
      t.column :remember_token_expires_at, :datetime
      t.column :activation_code,           :string, :limit => 40
      t.column :activated_at,              :datetime
      t.column :is_admin,                  :boolean, :default => false
      t.references :department
      t.references :branch_office
      t.float :hours
      t.float :salary
      t.string :genre

    end
    add_index :users, :login, :unique => true
    u = User.new
    u.login = 'admin'
    u.name = 'Administrator'
    u.password = '123456'
    u.password_confirmation = '123456'
    u.email = 'admin@admin.com'
    u.is_admin = true
    u.hours = 0
    u.salary = 0
    u.department_id = 0
    u.branch_office_id = 0
    u.save!
    u.activate!
  end

  def self.down
    drop_table "users"
  end
end
